using System.Collections;
using System.IO;
using UnityEngine;

public class ShareScreenShot : MonoBehaviour
{
	private string shareScore;

	private string shareTotalCoins;

	public string subject = "Stickman Shooter -Dismouting Zombie";

	public string URLShare = "";

	public void ButtonShare()
	{
		Object.FindObjectOfType<SoundMusicManager>().CameraSound();
		shareScore = string.Concat(PlayerPrefs.GetInt(BadLogic.nameMap + "BESTSCORE"));
		shareTotalCoins = string.Concat(PlayerPrefs.GetInt("COIN"));
		StartCoroutine(TakeSSAndShare());
	}

	private IEnumerator TakeSSAndShare()
	{
		yield return new WaitForEndOfFrame();
		Texture2D texture2D = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, mipChain: false);
		texture2D.ReadPixels(new Rect(0f, 0f, Screen.width, Screen.height), 0, 0);
		texture2D.Apply();
		string text = Path.Combine(Application.temporaryCachePath, "shared img.png");
		File.WriteAllBytes(text, texture2D.EncodeToPNG());
		UnityEngine.Object.Destroy(texture2D);
		new NativeShare().AddFile(text).SetSubject(subject).SetText("LOL!!! ,Break all physical rules with -Hurting Stickman Ragdoll- |My Best Score:" + shareScore + "|My TotalCoins:" + shareTotalCoins + "|Link Download:" + URLShare)
			.Share();
	}
}
